A virtual machine is platform-independent software for executing a program. Recent years, virtual machines are implemented on various home appliances equipped with processors such as built-in devices.
One exemplary virtual machine is a Java Virtual Machine (JVM) which interprets and executes Java (Registered Trademark) bytecodes (hereinafter simply “bytecodes”). Detailed specifications of JVM are found in “The Java Virtual Machine Specification, Second Edition” (published by Pearson Education, ISBN 4-89471-356-X).
Generally, bytecodes are generated by a Java compiler, such as Javac, by converting a source program written in the Java language. Bytecodes are stored in so-called class files with extension “.class”.
The JVM interprets class files and performs control required to causes a processor to execute methods included in the class files. A method is a set of bytecodes for execution of a specific procedure and similar to a member function in other programming languages.
Basically, the JVM works as an interpreter sequentially interpreting bytecodes at runtime. As is generally noted, the execution speed of a bytecode program is lower than the execution speed of a native code program directly executable by a processor. Especially, execution of a program in which the same method is repeatedly invoked involves excess overhead because the same method is repeatedly interpreted each time it is invoked.
To reduce the above overhead, there has been suggested a JVM having a Just-In-Time (JIT) compiler. A JIT compiler converts an invoked method into native code if it is judged that the method has not yet been compiled.
A JIT improves the execution speed because a processor is allowed to execute previously compiled native code when the same method is invoked for a second time.
Also, there is an extension technology of JIT compiler, which is a technique called Java HotSpot (Registered Trademark) capable of determining a method to be compiled into native code. More specifically, Java Hotspot keeps count of the number of times each method is invoked during program execution and compiles the method into native code when the count exceeds a threshold.
JP patent application publication Nos. H4-178734 and S64-62705 disclose program execution control devices having functions of both interpreter and compiler, similarly to the JVM having a JIT compiler.
One problem of JVM having JITs is as follows. The JVM starts compiling a method immediately upon invocation of the method, if the method has not yet been compiled. The resulting native code is executed by a processor when the compilation is done. Thus, the execution speed of an uncompiled method is slower, comparing the interpreter execution of the same method. Reduction in execution speed is especially notable at the initial stage of program execution because more bytecodes need to be compiled.
Similarly, the Java HotSpot technology suffers from the slower execution speed when compilation of an uncompiled method is carried out upon invocation. The method cannot be executed until the compilation is done.